package com.gdd.videos.common.util;

import org.apache.tomcat.util.codec.binary.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author zhangh     
 * @version V1.0.0
 * @projectName parent
 * @title     MD5Utils   
 * @package    com.gdd.videos.common  
 * @date   2019/9/2 17:14  
 * @explain
 */
public class MD5Utils {

    /**
     * 对字符串进行MD5加密
     */
    public static String getMD5Str(String sourcesStr) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        String newStr = Base64.encodeBase64String(md5.digest(sourcesStr.getBytes()));
        return newStr;
    }
    //
    //public static void main(String[] args) throws Exception {
    //    String md5Str = getMD5Str("123");
    //    System.out.println(md5Str);
    //}
}
